package com.youkeda.redpacket.dataobject;

import java.io.Serializable;
import java.util.Date;
import java.util.UUID;

import com.youkeda.redpacket.model.User;
import com.youkeda.redpacket.model.UserRedEnvelopeRecord;
import com.youkeda.redpacket.util.UUIDUtils;
import lombok.Data;
import org.springframework.beans.BeanUtils;
import org.springframework.util.StringUtils;

/**
 * user_red_envelope_record
 * @author 
 */
@Data
public class UserRedEnvelopeRecordDO implements Serializable {
    /**
     * 主键id
     */
    private String id;

    /**
     * 预制红包id
     */
    private String preSingleRedEnvelopeId;

    /**
     * 红包id
     */
    private String redEnvelopeId;

    /**
     * 用户id
     */
    private String userId;


    /**
     * 红包备注信息
     */
    private String note;

    /**
     * 创建时间
     */
    private Date gmtCreated;

    /**
     * 修改时间
     */
    private Date gmtModified;

    private static final long serialVersionUID = 1L;

    public UserRedEnvelopeRecordDO(UserRedEnvelopeRecord userRedEnvelopeRecord){
        if (StringUtils.isEmpty(userRedEnvelopeRecord.getId())){
            this.id = UUIDUtils.getUUID();
        }
        this.userId = userRedEnvelopeRecord.getUserId();
        this.preSingleRedEnvelopeId = userRedEnvelopeRecord.getPreSingleRedEnvelopeId();
        this.redEnvelopeId = this.getRedEnvelopeId();
        this.note = this.getNote();
    }

    public UserRedEnvelopeRecord convertToModel(){
        UserRedEnvelopeRecord record = new UserRedEnvelopeRecord();
        BeanUtils.copyProperties(this,record);

        return  record;
    }

}